//
//  ViewController.m
//  CustomButton
//
//  Created by leeson on 2018/2/5.
//  Copyright © 2018年 李斯芃 ---> 512523045@qq.com. All rights reserved.
//

#import "ViewController.h"
#import "HCButton.h"

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
/** 宽度系数适配(5.5寸为参照) */
#define ViewScale(num) (SCREEN_WIDTH/414.0 * num)

@interface ViewController ()
@property (weak, nonatomic) IBOutlet HCButton *printBt;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //xib方法
    self.printBt.space = 10.0;
    
    //自定义初始化方法
    HCButton *bt = [[HCButton alloc] initWithFrame:CGRectMake(ViewScale(50), ViewScale(100), ViewScale(100), ViewScale(100)) withImage:@"warning" andTitle:@"警告" andSpace:10.0];
    bt.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:.3];
    [self.view addSubview:bt];
    
    //自定义初始化方法（带参数buttonType）
    HCButton *bt1 = [HCButton buttonWithType:UIButtonTypeCustom andFrame:CGRectMake(ViewScale(160), ViewScale(100), ViewScale(100), ViewScale(100)) andImage:@"print" andTitle:@"打印" andSpace:10];
    [bt1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    bt1.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:.3];
    [self.view addSubview:bt1];
    
    //系统初始化方法
    HCButton *bt2 = [HCButton buttonWithType:UIButtonTypeCustom];
    //HCButton *bt2 = [[HCButton alloc] init];
    bt2.frame = CGRectMake(ViewScale(270), ViewScale(100), ViewScale(100), ViewScale(100));
    [bt2 setImage:[UIImage imageNamed:@"print"] forState:UIControlStateNormal];
    [bt2 setTitle:@"打印" forState:UIControlStateNormal];
    [bt2 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    bt2.space = 10.0;
    bt2.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:.3];
    [self.view addSubview:bt2];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
